home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d8 / toes114g.arc / TOES_CFG.SLT < prev    next >
Text File  |  1991-05-21  |  14KB  |  491 lines

  1. // TOES_CFG.SLT - toes configuration script
  2. // written by Allan Marillier, April 1991 as a supplemental program
  3. // to TOES.SLT. This script generates/edits a file named TOES.CNF which is
  4. // the required configuration for the TOES main script
  5.  
  6. ////////////////////////////////////////////////////////////////////////////
  7. str my_screen_shows_color[1];  // If you have a colour screen,
  8.                             // this will be 1. If mono, it will be 0
  9. str dial_str[10];           // This string must be modified.
  10.                             // In my dialing directory, the Fido
  11.                             // numbers are 1 and 2. Your numbers go in here.
  12. str user_name[60];          // user name goes here
  13. str toes_msg_file[80];      // Mail packet file name
  14. str toes_rep_file[80];      // Mail packet reply name
  15. str my_reply_dir[80];       // Reply file directory for upload
  16. str my_mail_dir[80];        // Mail packet directory for download
  17. str make_date_packet[1];    // if you want the script to
  18.                             // make a copy of the file GCOBBS.OPX
  19.                             // in the format YYMMDDnn.OPX, this will be
  20.                             // equal to 1, otherwise it will be 0
  21. str zmodem_protocol[1];           // this will be 0 for Telix's internal
  22.                             // Zmodem, or 1 for an external DSZ
  23. str auto_zap_opx[1];        // this will be 1 if old OPX's are to be auto
  24.                             // deleted or 0 if you want to be prompted
  25.                             // Note - if you use DSZ, this SHOULD be 1 as well
  26. str i_send_password[1];     // Password sent from config, or Telix dialling dir
  27. str user_password[50];      // replacement password
  28. str buffer[80];
  29. int kount;
  30. int file_handle;
  31. //////////////////////////////////////////////////////////////////////////////
  32. main()
  33. {
  34.   // set defaults
  35.   my_screen_shows_color = "N";
  36.   dial_str = "1 2";
  37.   user_name = "Jan Pierewiet";
  38.   toes_msg_file = "GCOBBS.OPX";
  39.   toes_rep_file = "GCOBBS.REP";
  40.   my_reply_dir = "C:\XPRESS\REPLY\";
  41.   my_mail_dir = "C:\XPRESS\MAIL\";
  42.   make_date_packet = "N";
  43.   zmodem_protocol = "I";
  44.   auto_zap_opx = "N";
  45.   i_send_password = "N";
  46.   user_password = "Choose_a_password:-50_chars";
  47.  
  48.   get_config();   // read config from file, if it exists. If not, set defaults
  49.   set_config();   // allow editing of config, and write back to disk
  50. }
  51. //////////////////////////////////////////////////////////////////////////////
  52. set_config()
  53. // read config from file, if it exists. If not, set defaults
  54. {
  55.   str s[100];
  56.   int c, i, stat;
  57.  
  58.   while (1)
  59.   {
  60.     clear_scr();
  61.     prints("^M^J           TOES Configuration Script^M^J");
  62.     printsc("A: Colour Display                      : ");
  63.     if (my_screen_shows_color == "Y")
  64.       prints("Yes");
  65.     else
  66.       prints("No");
  67.     printsc("B: Dialing Directory Entries           : ");
  68.     prints(dial_str);
  69.     printsc("C: User Name (as defined to BBS)       : ");
  70.     prints(user_name);
  71.     printsc("D: Mail File Name                      : ");
  72.     prints(toes_msg_file);
  73.     printsc("E: Reply File Name                     : ");
  74.     prints(toes_rep_file);
  75.     printsc("F: Mail Directory                      : ");
  76.     prints(my_mail_dir);
  77.     printsc("G: Reply Directory                     : ");
  78.     prints(my_reply_dir);
  79.     printsc("H: Date Named Backup                   : ");
  80.     if (make_date_packet == "Y")
  81.       prints("Yes");
  82.     else
  83.       prints("No");
  84.     printsc("I: Z-Modem - Internal, Dsz, Pcz        : ");
  85.     if (zmodem_protocol == "I")
  86.       prints("Internal");
  87.     else
  88.     if (zmodem_protocol == "D")
  89.       prints("DSZ");
  90.     else
  91.     if (zmodem_protocol == "P")
  92.       prints("PCZ");
  93.     printsc("J: Automatically Destroy Existing .OPX : ");
  94.     if (auto_zap_opx == "Y")
  95.       prints("Yes");
  96.     else
  97.       prints("No");
  98.     printsc("K: Read TOES Config file for password  : ");
  99.     if (i_send_password == "Y")
  100.       prints("Yes");
  101.     else
  102.       prints("No");
  103.     printsc("L: BBS Password                        : ");
  104.     prints(user_password);
  105.  
  106.     prints("^M^JW: Exit and save changes to disk.^M^J");
  107.     prints("X: Exit without saving changes.");
  108.  
  109.     printsc("Which option? ");
  110.     gets(s, 1);
  111.     prints("");
  112.     c = toupper(subchr(s, 0));
  113.     if (c < 'A' || c > 'L' && c != 'W' && c != 'X')
  114.       continue;
  115.     if (c >= 'A' && c <= 'L')
  116.       printsc("Enter new value (Esc to abort): ");
  117.     if (c == 'A')
  118.     // chose A - my_screen_shows_color
  119.     {
  120.       prints("< Y / N >");
  121.       stat = gets(s,1);
  122.       if (stat != -1)
  123.       {
  124.         my_screen_shows_color = s;
  125.         strupper(my_screen_shows_color);
  126.       }
  127.     }
  128.     else
  129.     if (c == 'B')
  130.     // chose B - dial_str
  131.     {
  132.       prints("");
  133.       stat = gets(s,80);
  134.       if (stat != -1)
  135.       {
  136.         dial_str = s;
  137.         strupper(dial_str);
  138.       }
  139.     }
  140.     else
  141.     if (c == 'C')
  142.     // chose C - user_name
  143.     {
  144.       prints("");
  145.       stat = gets(s,80);
  146.       if (stat != -1)
  147.       {
  148.         user_name = s;
  149.         strupper(user_name);
  150.       }
  151.     }
  152.     else
  153.     if (c == 'D')
  154.     // chose D - toes_msg_file
  155.     {
  156.       prints("");
  157.       stat = gets(s,80);
  158.       if (stat != -1)
  159.       {
  160.         toes_msg_file = s;
  161.         strupper(toes_msg_file);
  162.       }
  163.     }
  164.     else
  165.     if (c == 'E')
  166.     // chose E - toes_rep_file
  167.     {
  168.       prints("");
  169.       stat = gets(s,80);
  170.       if (stat != -1)
  171.       {
  172.         toes_rep_file = s;
  173.         strupper(toes_rep_file);
  174.       }
  175.     }
  176.     else
  177.     if (c == 'F')
  178.     // chose F - my_mail_dir
  179.     {
  180.       prints("");
  181.       stat = gets(s,80);
  182.       if (stat != -1)
  183.       {
  184.         my_mail_dir = s;
  185.         strupper(my_mail_dir);
  186.       }
  187.       if ((i = strlen(my_mail_dir)) != 0)       // add slash if needed
  188.         if (subchr(my_mail_dir, i - 1) != '\')
  189.           copystr("\", my_mail_dir, i, 1);
  190.     }
  191.     else
  192.     if (c == 'G')
  193.     // chose G - my_reply_dir
  194.     {
  195.       prints("");
  196.       stat = gets(s,80);
  197.       if (stat != -1)
  198.       {
  199.         my_reply_dir = s;
  200.         strupper(my_reply_dir);
  201.       }
  202.       if ((i = strlen(my_reply_dir)) != 0)       // add slash if needed
  203.         if (subchr(my_reply_dir, i - 1) != '\')
  204.           copystr("\", my_reply_dir, i, 1);
  205.     }
  206.     else
  207.     if (c == 'H')
  208.     // chose H - make_date_packet
  209.     {
  210.       prints("< Y / N >");
  211.       stat = gets(s,1);
  212.       if (stat != -1)
  213.       {
  214.         make_date_packet = s;
  215.         strupper(make_date_packet);
  216.       }
  217.     }
  218.     else
  219.     if (c == 'I')
  220.     // chose I - zmodem_protocol
  221.     {
  222.       prints("< I / D / P >");
  223.       stat = gets(s,1);
  224.       if (stat != -1)
  225.       {
  226.         zmodem_protocol = s;
  227.         strupper(zmodem_protocol);
  228.       }
  229.     }
  230.     else
  231.     if (c == 'J')
  232.     // chose J - auto_zap_opx
  233.     {
  234.       prints("< Y / N >");
  235.       stat = gets(s,1);
  236.       if (stat != -1)
  237.       {
  238.         auto_zap_opx = s;
  239.         strupper(auto_zap_opx);
  240.       }
  241.     }
  242.     else
  243.     if (c == 'K')
  244.     // chose K - i_send_password
  245.     {
  246.       prints("< Y / N >");
  247.       stat = gets(s,1);
  248.       if (stat != -1)
  249.       {
  250.         i_send_password = s;
  251.         strupper(i_send_password);
  252.       }
  253.     }
  254.     else
  255.     if (c == 'L')
  256.     // chose L - user_password
  257.     {
  258.       prints("");
  259.       stat = gets(s,80);
  260.       if (stat != -1)
  261.       {
  262.         user_password = s;
  263.         strupper(user_password);
  264.       }
  265.     }
  266.     else
  267.     if (c == 'X')
  268.     // chose X to exit with no change
  269.     {
  270.       prints("^M^JTOES Configuration done - no changes made.^M^J");
  271.       delay(40);
  272.       return;
  273.     }
  274.     else
  275.     if (c == 'W')
  276.     // chose W - write to file
  277.     {
  278.       s = _telix_dir;
  279.       strcat(s,"TOES.CNF");
  280.       file_handle = fopen(s,"w");
  281.       if (!file_handle)
  282.       // problem opening the file
  283.       {
  284.         printsc("TOES configuration : ");
  285.         printsc("Error writing to ");
  286.         printsc(s);
  287.         prints("!");
  288.         delay(40);
  289.         continue;
  290.       }
  291.       // write the data to file
  292.       fputs(my_screen_shows_color,file_handle);
  293.       fputs("^M^J",file_handle);
  294.       fputs(dial_str,file_handle);
  295.       fputs("^M^J",file_handle);
  296.       fputs(user_name,file_handle);
  297.       fputs("^M^J",file_handle);
  298.       fputs(toes_msg_file,file_handle);
  299.       fputs("^M^J",file_handle);
  300.       fputs(toes_rep_file,file_handle);
  301.       fputs("^M^J",file_handle);
  302.       fputs(my_reply_dir,file_handle);
  303.       fputs("^M^J",file_handle);
  304.       fputs(my_mail_dir,file_handle);
  305.       fputs("^M^J",file_handle);
  306.       fputs(make_date_packet,file_handle);
  307.       fputs("^M^J",file_handle);
  308.       fputs(zmodem_protocol,file_handle);
  309.       fputs("^M^J",file_handle);
  310.       fputs(auto_zap_opx,file_handle);
  311.       fputs("^M^J",file_handle);
  312.       fputs(i_send_password,file_handle);
  313.       fputs("^M^J",file_handle);
  314.       fputs(user_password,file_handle);
  315.       fputs("^M^J",file_handle);
  316.  
  317.       fclose(file_handle);
  318.       prints("^M^JTOES CONFIG done.^M^J");
  319.       delay(30);
  320.       return;
  321.     }
  322.   }  // end while
  323. }  // end function set_config
  324. ////////////////////////////////////////////////////////////////////////////
  325. get_config()
  326. // check for and read the config file. If none exists, create it
  327. // using the defaults, and allow editing
  328. {
  329.   if (filefind("TOES.CNF",3,buffer) != 0)
  330.   {
  331.     // it exists, so read it
  332.     // if it doesn't exist, return to main. set_config will create it
  333.     file_handle = fopen("TOES.CNF","r");
  334.     // get value for colour screen
  335.     buffer = "";
  336.     if (fgets(buffer,3,file_handle) == -1)
  337.     {
  338.        fclose(file_handle);
  339.        panic();
  340.      }
  341.      strupper(buffer);
  342.      if (buffer == "Y" || buffer =="N")
  343.        my_screen_shows_color = buffer;
  344.  
  345.      // get value for dial string
  346.      buffer = "";
  347.      if (fgets(buffer,80,file_handle) == -1)
  348.      {
  349.        fclose(file_handle);
  350.        panic();
  351.      }
  352.      strupper(buffer);
  353.      dial_str = buffer;
  354.      // how do I check this ? I think that's the user's responsibility
  355.  
  356.      // get value for user_name
  357.      buffer = "";
  358.      if (fgets(buffer,80,file_handle) == -1)
  359.      {
  360.        fclose(file_handle);
  361.        panic();
  362.      }
  363.      strupper(buffer);
  364.      user_name = buffer;
  365.      // strcat(user_name,";y"); - only necessary for TOES itself
  366.  
  367.      // get value for toes_msg_file
  368.      buffer = "";
  369.      if (fgets(buffer,80,file_handle) == -1)
  370.      {
  371.        fclose(file_handle);
  372.        panic();
  373.      }
  374.      strupper(buffer);
  375.      toes_msg_file = buffer;
  376.  
  377.      // get value for toes_rep_file
  378.      buffer = "";
  379.      if (fgets(buffer,80,file_handle) == -1)
  380.      {
  381.        fclose(file_handle);
  382.        panic();
  383.      }
  384.      strupper(buffer);
  385.      toes_rep_file = buffer;
  386.  
  387.      // get value for my_reply_dir
  388.      buffer = "";
  389.      if (fgets(buffer,80,file_handle) == -1)
  390.      {
  391.        fclose(file_handle);
  392.        panic();
  393.      }
  394.      strupper(buffer);
  395.      my_reply_dir = buffer;
  396.  
  397.      // get value for my_mail_dir
  398.      buffer = "";
  399.      if (fgets(buffer,80,file_handle) == -1)
  400.      {
  401.        fclose(file_handle);
  402.        panic();
  403.      }
  404.      strupper(buffer);
  405.      my_mail_dir = buffer;
  406.  
  407.      // get value for make_date_packet
  408.      buffer = "";
  409.      if (fgets(buffer,3,file_handle) == -1)
  410.      {
  411.        fclose(file_handle);
  412.        panic();
  413.      }
  414.      strupper(buffer);
  415.      if (buffer == "Y" || buffer == "N")
  416.        make_date_packet = buffer;
  417.  
  418.      // get value for zmodem_protocol
  419.      buffer = "";
  420.      if (fgets(buffer,3,file_handle) == -1)
  421.      {
  422.        fclose(file_handle);
  423.        panic();
  424.      }
  425.      strupper(buffer);
  426.      if (buffer == "I" || buffer == "D" || buffer == "P")
  427.        zmodem_protocol = buffer;
  428.  
  429.      // get value for auto_zap_opx
  430.      buffer = "";
  431.      if (fgets(buffer,3,file_handle) == -1)
  432.      {
  433.        fclose(file_handle);
  434.        panic();
  435.      }
  436.      strupper(buffer);
  437.      if (buffer == "Y" || buffer == "N")
  438.        auto_zap_opx = buffer;
  439.  
  440.      // get value for i_send_password
  441.      buffer = "";
  442.      if (fgets(buffer,3,file_handle) == -1)
  443.      {
  444.        fclose(file_handle);
  445.        panic();
  446.      }
  447.      strupper(buffer);
  448.      if (buffer == "Y" || buffer == "N")
  449.        i_send_password = buffer;
  450.  
  451.      // get value for user_password
  452.      buffer = "";
  453.      if (fgets(buffer,53,file_handle) == -1)
  454.      {
  455.        fclose(file_handle);
  456.        panic();
  457.      }
  458.      strupper(buffer);
  459.      user_password = buffer;
  460.  
  461.     fclose(file_handle);
  462.   }
  463. } // end function get_config
  464. ////////////////////////////////////////////////////////////////////////////
  465. panic()
  466. {
  467.   // panic exit from get_config - due to corrupt file etc.
  468.   prints("PANIC exit from TOES script attempting to read the config file");
  469.   prints("  TOES.CNF. Something is wrong ! The file is corrupt, or otherwise");
  470.   prints("  inaccessible. If it exists, try deleting it. This script will ");
  471.   prints("  automatically recreate it. If that fails, try viewing it. It ");
  472.   prints("  should appear in the format shown below :");
  473.   prints("N");
  474.   prints("1 2");
  475.   prints("GCOBBS.OPX");
  476.   prints("GCOBBS.REP");
  477.   prints("C:\XPRESS\REPLY\");
  478.   prints("C:\XPRESS\MAIL\");
  479.   prints("N");
  480.   prints("I");
  481.   prints("Y");
  482.   prints("N");
  483.   prints("Choose_a_password:-50_chars");
  484.   prints("");
  485.   prints(" If errors persist - please contact Allan Marillier at 5:491/1");
  486.   fclose(file_handle);
  487.   delay(40);
  488.   exittelix();
  489. } // end function panic
  490. ////////////////////////////////////////////////////////////////////////////
  491.